home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- CWASTEClipboard.cpp
-
- A derived class of CClipboard that displays 'TEXT', 'soup', and 'styl'
-
- To use this class in your application, you should override
- CApplication::MakeClipboard, as in:
-
- void CMyApp::MakeClipboard()
- {
- CWASTEClipboard *wasteClip = TCL_NEW(CWASTEClipboard,(true));
-
- gClipboard = wasteClip;
- }
-
-
- By Dan Crevier, 1996
- ******************************************************************************/
-
- #ifdef TCL_PCH
- #include <TCLHeaders>
- #endif
-
- #include "CWASTEClipboard.h"
- #include "CScrollPane.h"
- #include "Global.h"
-
- #include "CWASTEText.h"
-
- /******************************************************************************
- CWASTEClipboard
-
- Constructor
- ******************************************************************************/
-
- CWASTEClipboard::CWASTEClipboard(Boolean hasWindow)
- : CClipboard(hasWindow)
- {
- }
-
-
- /******************************************************************************
- IWASTEClipboard
-
- Initialize a CWASTEClipboard
- ******************************************************************************/
-
- void CWASTEClipboard::IWASTEClipboard(CApplication *aSupervisor,
- Boolean hasWindow)
- {
- CClipboard::IClipboard(aSupervisor, hasWindow);
- }
-
-
- /******************************************************************************
- MakeClipView
-
- This method makes a panorama to display the current clipboard data.
-
- ******************************************************************************/
-
- CPanorama* CWASTEClipboard::MakeClipView(long dataType, Handle dataHandle)
- {
- Handle styleHandle = NULL;
- #if WASTE_VERSION >= 0x01100000
- Handle soupHandle = NULL;
- #endif
- CWASTEText *volatile text = NULL;
- Rect margin;
- CPanorama *panorama = NULL;
-
- try_
- {
- if (dataType == 'TEXT')
- {
- GetData('styl', &styleHandle);
- #if WASTE_VERSION >= 0x01100000
- GetData('SOUP', &soupHandle);
- #endif
- text = TCL_NEW(CWASTEText,());
-
- text->IWASTEText(itsScrollPane, this,
- 1, 1, 0, 0, sizELASTIC, sizELASTIC, 1000);
- text->Specify(kNotEditable, kNotSelectable, kNotStylable);
- text->FitToEnclosure(TRUE, TRUE);
- text->Offset(2, 2, FALSE);
- SetRect(&margin, 0, 0, -2, -2);
- text->ChangeSize(&margin, FALSE);
-
- MoveHHi(dataHandle);
- HLock(dataHandle);
-
-
- #if WASTE_VERSION >= 0x01100000
- text->InsertWithStyleSoup(*dataHandle, GetHandleSize(dataHandle),
- (StScrpHandle) styleHandle, soupHandle, true);
- #else
- text->InsertWithStyle(*dataHandle, GetHandleSize(dataHandle),
- (StScrpHandle) styleHandle, true);
- #endif
- TCLForgetHandle(dataHandle);
- TCLForgetHandle(styleHandle);
- #if WASTE_VERSION >= 0x01100000
- TCLForgetHandle(soupHandle);
- #endif
- panorama = text;
- }
- }
- catch_all_()
- {
- if (dataType == 'TEXT')
- {
- TCLForgetObject(text);
- TCLForgetHandle(dataHandle);
- TCLForgetHandle(styleHandle);
- #if WASTE_VERSION >= 0x01100000
- TCLForgetHandle(soupHandle);
- #endif
- }
- throw_same_();
- }
- end_try_
-
- return panorama;
- }
-